package cn.deu.xunwu;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.dzu.dao.XunwuDao;
import cn.dzu.entity.Xunwu;

/**
 * Servlet implementation class selectall
 */
@WebServlet("/selectall")
public class selectall extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public selectall() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
		  XunwuDao xunwu=(XunwuDao)applicationContext.getBean("XunwuDao");		
		     List <Xunwu> list=xunwu.queryAll( );
	        request.setAttribute("all1", list);	     
	        request.getRequestDispatcher("/All.jsp").forward(request, response);
	}

}
